﻿@model IEnumerable<BookClubPortal.Models.Book>
@helper Truncate(string
input, int length)
    {
        if (input != null)
        {

            if (input.Length <= length)
            {
                @input
            }
            else
            {
                @input.Substring(0, length)<text>...</text>
            }
        }
}     
@{
    ViewBag.Title = "Introduction";
}

@{
    var grid = new WebGrid(Model, defaultSort:"Name", canPage:true,rowsPerPage:10);
}


@section featured {
    <section class="featured">
        <div class="content-wrapper">
            <hgroup class="title">
                <h1>@ViewBag.Title</h1>
                <h2>@ViewBag.Message</h2>
            </hgroup>
            <p>
                On this awesome site you can offer your books you don't need anymore and browse books offered by others.
            </p>
            <p>
                We don't charge anything for this service and don't display prices for books.
                We suggest all our members that they offer their books for free and the postal costs should be paid by the receiver.
            </p>
            <p>
                We don't store any personal information beside your e-mail address, which we need to contact you regarding your offers and the books you requested.
                When you request a book we will ask for your address only to send it to the book's owner so they can send you the book.
            </p>
            <p>
                If you are interested please @Html.ActionLink("register", "Register", "Account") and start browsing!
            </p>
        </div>
    </section>
}
<h3>Some books offered on our site:</h3>

@grid.GetHtml(columns: grid.Columns(

   grid.Column("ImageURL", header: "Image", format: @<text><a href="@item.ImageURL" target="_blank"><img src="@item.ImageURL" alt="@item.Title" onerror="AltImage(this,'@Url.Content("~/Content/Images/logo.png")')" width="50" height="50"></a></text>),
    grid.Column("Title", format: @<text>@Truncate(@item.Title, 30)</text>),
    grid.Column("Author", format: @<text>@Truncate(@item.Author, 30)</text>),
    grid.Column("ReleaseYear", header: "Release Year"),
    grid.Column("Genre.Name", header: "Genre", format: @<text>@Truncate(@item.Genre.Name, 30)</text>),
    grid.Column("Description", header: "Description", format: @<text>@Truncate(@item.Description, 30)</text>)
                 
        
    ))

@section Scripts {
    @Scripts.Render("~/bundles/tools")
}
